#include<iostream>
using namespace std;
int main() {
	int i[1002], j[1002] = { 0 };
	int a, b, c, m, n;
	cin >> a;
	for (b = 0; b < a; b++) {
		cin >> i[b];
	}
	for (b = 0; b < a; b++) {
		for (c = b; c < a; c++) {
			if (i[b] == i[c])
				j[b]++;
		}
	}
	m = 0;
	n = j[0];
	for (b = 1; b < a; b++) {
		if (n < j[b]) {
			n = j[b];
			m = b;
		}
	}
	cout << i[m] << " " << j[m];
	return 0;
}